// src/main/java/com/xur/springboot/mapper/ChatMessageMapper.java
package com.xur.springboot.mapper;

import com.xur.springboot.entity.ChatMessage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;

@Mapper
@Component
public interface ChatMessageMapper {
    // 插入消息
    int insertMessage(ChatMessage message);

    // 查询历史消息
    List<ChatMessage> selectHistory(
            @Param("sender_id") Integer sender_id,
            @Param("receiver_id") Integer receiver_id);

    // 更新消息状态
    int updateMessageStatus(
            @Param("msg_id") Integer msg_id,
            @Param("status") Integer status);

    //根据sender_id查询聊天记录
    List<ChatMessage> selectChatMessageBysender_id(
            @Param("sender_id") Integer sender_id,
            @Param("receiver_id") Integer receiver_id);
    //根据sender_id查询聊天记录
    List<ChatMessage> selectChatHistory(
            @Param("sender_id") Integer sender_id,
            @Param("receiver_id") Integer receiver_id);

    // 新增方法：查询与指定用户有过聊天记录的所有去重用户ID
    List<Integer> selectRelatedUserIds(@Param("userId") Integer userId);
}